'Copyright (C) 2009 Christiaan Cable
'
'This program is free software; you can redistribute it and/or
'modify it under the terms of the GNU General Public License
'as published by the Free Software Foundation; either version 3
'of the License, or (at your option) any later version.
'
'This program is distributed in the hope that it will be useful,
'but WITHOUT ANY WARRANTY; without even the implied warranty of
'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'GNU General Public License for more details (LICENCE.TXT).

Imports System.Windows.Forms
Imports System.Net
Imports System.IO

Public Class ISPData
    'retrieve usage data from the isp

    Public ISPReturnData As ISPReturnData

    Public Sub New(ByVal NewConfigurationData As ConfigurationData)

        If NewConfigurationData.ISPName.ToLower = "aanet" Then
            ISPReturnData = New aaNet(NewConfigurationData).ISPReturnData
        ElseIf NewConfigurationData.ISPName.ToLower = "aapt" Then
            ISPReturnData = New AAPT(NewConfigurationData).ISPReturnData
        ElseIf NewConfigurationData.ISPName.ToLower = "aapt new" Then
            ISPReturnData = New AAPTNew(NewConfigurationData).ISPReturnData
        ElseIf NewConfigurationData.ISPName.ToLower = "adam" Then
            ISPReturnData = New Adam(NewConfigurationData).ISPReturnData
        ElseIf NewConfigurationData.ISPName.ToLower = "amnet" Then
            ISPReturnData = New amnet(NewConfigurationData).ISPReturnData
        ElseIf NewConfigurationData.ISPName.ToLower = "bettamomentum" Then
            ISPReturnData = New BettaMomentum(NewConfigurationData).ISPReturnData
        ElseIf NewConfigurationData.ISPName.ToLower = "blitz" Then
            ISPReturnData = New Blitz(NewConfigurationData).ISPReturnData
        ElseIf NewConfigurationData.ISPName.ToLower = "cirrus" Then
            ISPReturnData = New Cirrus(NewConfigurationData).ISPReturnData
        ElseIf NewConfigurationData.ISPName.ToLower = "comcen" Then
            ISPReturnData = New ComCen(NewConfigurationData).ISPReturnData
            'ElseIf NewConfigurationData.ISPName.ToLower = "comcen (new)" Then
            '    ISPReturnData = New ComCenNew(NewConfigurationData).ISPReturnData
            'ElseIf NewConfigurationData.ISPName.ToLower = "comcen (old)" Then
            '    ISPReturnData = New ComCenOld(NewConfigurationData).ISPReturnData
        ElseIf NewConfigurationData.ISPName.ToLower = "dodo" Then
            ISPReturnData = New dodo(NewConfigurationData).ISPReturnData
        ElseIf NewConfigurationData.ISPName.ToLower = "eftel" Then
            ISPReturnData = New EFTel(NewConfigurationData).ISPReturnData
        ElseIf NewConfigurationData.ISPName.ToLower = "exetel" Then
            ISPReturnData = New exetel(NewConfigurationData).ISPReturnData
        ElseIf NewConfigurationData.ISPName.ToLower = "exetel wireless" Then
            ISPReturnData = New exetelwireless(NewConfigurationData).ISPReturnData
        ElseIf NewConfigurationData.ISPName.ToLower = "g-node" Then
            ISPReturnData = New G_node(NewConfigurationData).ISPReturnData
        ElseIf NewConfigurationData.ISPName.ToLower = "internode" Then
            ISPReturnData = New Internode(NewConfigurationData).ISPReturnData
            'ElseIf NewConfigurationData.ISPName.ToLower = "iinet" Then
            '    ISPReturnData = New iiNet(NewConfigurationData).ISPReturnData
        ElseIf NewConfigurationData.ISPName.ToLower = "isage" Then
            ISPReturnData = New Isage(NewConfigurationData).ISPReturnData
        ElseIf NewConfigurationData.ISPName.ToLower = "netspace" Then
            ISPReturnData = New Netspace(NewConfigurationData).ISPReturnData
        ElseIf NewConfigurationData.ISPName.ToLower = "onthenet" Then
            ISPReturnData = New OntheNet(NewConfigurationData).ISPReturnData
        ElseIf NewConfigurationData.ISPName.ToLower = "optus" Then
            ISPReturnData = New Optus(NewConfigurationData).ISPReturnData
        ElseIf NewConfigurationData.ISPName.ToLower = "primus" Then
            ISPReturnData = New Primus(NewConfigurationData).ISPReturnData
        ElseIf NewConfigurationData.ISPName.ToLower = "soul" Then
            ISPReturnData = New Soul(NewConfigurationData).ISPReturnData
        ElseIf NewConfigurationData.ISPName.ToLower = "spin" Then
            ISPReturnData = New Spin(NewConfigurationData).ISPReturnData
        ElseIf NewConfigurationData.ISPName.ToLower = "supernerd" Then
            ISPReturnData = New SuperNerd(NewConfigurationData).ISPReturnData
        ElseIf NewConfigurationData.ISPName.ToLower = "telstra" Then
            ISPReturnData = New Telstra(NewConfigurationData).ISPReturnData
        ElseIf NewConfigurationData.ISPName.ToLower = "tpg" Then
            ISPReturnData = New TPG(NewConfigurationData).ISPReturnData
        ElseIf NewConfigurationData.ISPName.ToLower = "webshield" Then
            ISPReturnData = New Webshield(NewConfigurationData).ISPReturnData
        ElseIf NewConfigurationData.ISPName.ToLower = "westnet" Then
            ISPReturnData = New Westnet(NewConfigurationData).ISPReturnData
        Else
            'empty
            ISPReturnData = New ISPReturnData
        End If

        '###################################################################################

        'check for error
        If ISPReturnData.ErrorMessage <> "" Then
            ISPReturnData.Status = 3
        Else
            'Status ok
            ISPReturnData.Status = 2
        End If

        '###################################################################################

        If NewConfigurationData.LastNotify <> Format(Now.Date, "yyyyMMdd") Then

            ''call home once per day
            'If NewConfigurationData.SendStats = True Then
            '    If UnixDetected() = False Then
            '        NewShell(Application.StartupPath, Application.StartupPath & Path.DirectorySeparatorChar & "uanotify.exe", "", False)
            '    Else
            '        NewShell(Application.StartupPath, "mono", "uanotify.exe", False)
            '    End If
            'End If

            NewConfigurationData.LastNotify = Format(Now.Date, "yyyyMMdd")

            'if today is rollover day, reset alerts
            If NewConfigurationData.LastNotify = Format(ISPReturnData.RolloverDate, "yyyyMMdd") Then
                NewConfigurationData.Alert1Count = 0
                NewConfigurationData.Alert2Count = 0
                NewConfigurationData.Alert3Count = 0
                NewConfigurationData.Alert4Count = 0
                NewConfigurationData.Alert5Count = 0
            End If
        End If
    End Sub

End Class

